<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ page import="com.starbaba.core.web.constant.WebConstants"%>
<%@ page import="com.starbaba.system.user.model.UserVO"%>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<%@ include file="/common/common-css.jsp"%>
<style>
#jquery-table td {
	cursor: pointer !important
}

.load_bg {
	background: #000;
	opacity: 0.1;
	left: 0px;
	top: 0px;
	position: fixed;
	height: 100%;
	width: 100%;
	overflow: hidden;
	z-index: 10000;
}

.load_img {
	left: 50%;
	top: 180px;
	position: fixed;
	height: 50px;
	overflow: hidden;
	z-index: 20000;
}
</style>
</head>
<body class="no-skin">
	<div class="load_bg" style="display: none;"></div>
	<img src="http://img.tuanzidai.cn/commentloading.gif" class="load_img" style="display: none" />
	<div class="page-content">
		<div class="page-header" style="margin-bottom: 0px; padding-bottom: 10px;"></div>

		<form id="queryForm" method="post" enctype="multipart/form-data">
			
			<div class="page-content-area">
				<div class="row">
					<div class="col-sm-12">
					    <input type="hidden" id="suffix" name="suffix">
						<div class="widget-box" style="border: 0px solid #ccc; border-top: none; border-bottom: none;">
							<div class="widget-header widget-header-blue widget-header-flat">
								<h4 class="widget-title">上传订单</h4>
								<div class="widget-toolbar">
									<a href="#" data-action="collapse"><i class="ace-icon fa fa-chevron-up"></i></a>
								</div>
							</div>
							<div class=" widget-body">
								<div class="widget-main">
									<div class="form-group col-xs-12 col-sm-4">
										<label class="col-sm-2 control-label"  style="text-align:right">合作方：</label>
										 <div class="col-sm-8" style="padding-left: 0;">
											<select id="type" name="type" class="form-control">
												<option value="">---请选择---</option>
												<!-- <option value="1">捷信福贷</option> -->
												<option value="2">宜信信贷</option>
												<option value="3">恒昌</option>
											</select>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					
					<div class="col-md-12 center">
						<div class="clearfix form-actions">
							<span id="upload"> 
								<input id="upload_file" name="upload" type="file" style="display: none"/>
								<input id="upload_btn" type='button' class='btn' value='上传' />
							</span>
						</div>
					</div>
				</div>
			</div>
	</form>
</div>
<%@ include file="/common/common-js.jsp"%>
<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
<script type="text/javascript" src="${ctx}/ace/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
    
	$('#upload_btn').click(function() {
		if ($("#type").val() == "") {
			return alert("请选择合作方");
		}
		$('#upload_file').trigger('click');
	});

	$('#upload_file').change(
		function() {
			var filename = $("#upload_file").val();
			var extStart = filename.lastIndexOf(".");
			var ext = filename.substring(extStart + 1, filename.length)
					.toUpperCase();
			
			if ("XLSX" != ext && "XLS" != ext) {
				return alert("文件格式错误,请导入excel文件");
			}
			
			$("#suffix").val(ext);
			var form = new FormData(document.forms["queryForm"]);
			
		    $.ajax({
				url : ctx + "/loanorder/upload.action",
				type : "post",
				data : form,
				processData : false,
				contentType : false,
				beforeSend : function(){
					showLoading();
				},
				success : function(data) {
					var total = JSON.parse(data).total;
					var success = JSON.parse(data).success;
					alert("TOTAL："+ total + "，SUCCESS：" + success);
				},
				error : function(e) {
					alert("error");
				},
				complete: function(xhr, status) {
					hideLoading();
				}
		   });
	 });
	
	function showLoading() {
		$(".load_bg").show();
		$(".load_img").show();
	}
	
	function hideLoading() {
		$(".load_bg").hide();
		$(".load_img").hide();
	}
</script>
</body>
</html>